import java.awt.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.List;
import javax.swing.*;

import java.awt.event.*;

public class Client extends JPanel implements MouseListener, MouseMotionListener{
	private Image background,go,cList,cDet,add,edit;
	private int goNext=0;
	private JTable list1;
	String data[][];
	
	public Client(){
		//JButton but = new JButton("HELLO");
		//add(but);
		String[] colnam = {""};
		data = new String[100][100];
		data[0][0] = "NAME1";
		data[1][0] = "NAME2";
		data[2][0] = "NAME3";
		setLayout(null);
		JTextField search = new JTextField();
		add(search);
		search.setBounds(190,18,150,30);
		loadImages();
		list1 = new JTable(data,colnam);
		Font font = new Font("Verdana", Font.BOLD, 30);
		list1.setFont(font);
		list1.setForeground(Color.blue);
		//list1.setGridColor(Color.white);
		list1.setBackground(new Color(0xee,0xe9,0xea));
		list1.setRowHeight(30);
        list1.setPreferredScrollableViewportSize(new Dimension(500, 70));
		list1.setFillsViewportHeight(false);//tru dpt
		JScrollPane scrollPane2 = new JScrollPane(list1);
		scrollPane2.setBounds(38, 108, 346, 303);
		add(scrollPane2);
		addMouseListener(this);
	}
	
	 public void loadImages(){
	       try{
	           background = new ImageIcon("pics/stan_bg.png").getImage();
	           go = new ImageIcon("pics/go.png").getImage();
	           cList = new ImageIcon("pics/clientlist.png").getImage();
	           cDet = new ImageIcon("pics/clientdetails.png").getImage();
	           add = new ImageIcon("pics/addbutton.png").getImage();
	           edit = new ImageIcon("pics/editbutton.png").getImage();
	           
	        } catch (Exception e) { }
	       
	       repaint();
	   }
	   
	   public void paintComponent(Graphics g){
	       super.paintComponent(g);
	       Graphics2D g2d = (Graphics2D) g;
	       setForeground(Color.red);
	       setFont(new Font("Arial",Font.BOLD,25));
	       g2d.drawImage(background, 0, 0, this);
	       g2d.drawString("Search client:" , 20, 40);
	       g2d.drawImage(go, 350, 10, this);
	       g2d.drawImage(cList, 30, 70, this);
	       g2d.drawImage(cDet, 450, 70, this);
	       g2d.drawImage(add, 40, 430, this);
	       g2d.drawImage(edit, 510, 430, this);
	       g2d.drawImage(add, 460, 430, this);
	   }
	   
	   public void setGoNext(int d){
		   goNext=1;
	   }
	   
	   public int getGoNext(){
		  return goNext; 
	   }
	   
	   public void Loopy(){
			while(goNext!=1)
				repaint();
			}
	   
	   public void mouseClicked(MouseEvent me) {
		   if(me.getY() >= 10 && me.getY() <= 52)
			{if(me.getX()>=350 && me.getX()<=396){
				System.out.println("GO BUTTON");
			}
			}
		   
		   if(me.getY() >= 430 && me.getY() <= 467)
			{if(me.getX()>=40 && me.getX()<=81){
				System.out.println("Add 1");
			}
			else if(me.getX()>=460 && me.getX()<=501){
				System.out.println("Add 2");
			}
			else if(me.getX()>=510 && me.getX()<=551){
				System.out.println("Delete");
			}
			}
		   	
	   }
	   public void mousePressed(MouseEvent me) {
	       
	   }
	   public void mouseReleased(MouseEvent me) {
	       
	   }
	   public void mouseDragged(MouseEvent me) {
	       
	   }
	   public void mouseMoved(MouseEvent me) {
	   
	   }    
	   public void mouseEntered(MouseEvent me) {
	       
	   }
	   public void mouseExited(MouseEvent me) {
	       
	   }
}
